<%@page import="org.book.service.UserService"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.book.dao.*" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<%-- 静态包含 base标签、css样式、jQuery文件 --%>
	<%@ include file="/pages/common/head.jsp"%>
<script type="text/javascript">
			// 页面加载完成之后
			$(function () {
				// 给注册绑定单击事件
				$("#sub_btn").click(function () {
					var name = $("#name").val();
					if (name == null || name == "") {
						//4 提示用户
						$("span.errorMsg").text("姓名不能为空！");

						return false;
					}
					var password = $("#password").val();
					if (password == null || password == "") {
						//4 提示用户
						$("span.errorMsg").text("卡号不能为空！");

						return false;
					}
				});

			});

		</script>
</head>
<body>
	<%
		//保持页码
		String pageCurrent2 = request.getParameter("pageCurrent2");
		String no = request.getParameter("no");
		/*if(no==null||pageCurrent2==null){
			request.getRequestDispatcher("../../index.jsp").forward(request, response);
			return;
		}*/
		int id = -1;
		String userName = "";
		String cardNumber = "";
		
		String str1 = "添加用户";
		String str2 = "输入添加信息";
		//修改
		if(no!=null){
			id = Integer.parseInt(no);
			UserService userService = new UserService();
			UserBean stu = userService.getStuByNo(id);
			userName = stu.getUserName();
			cardNumber = stu.getCardNumber();
			
			str1 = "修改用户";
			str2 = "输入修改信息";
		}
		
	%>
	
	<div id="login_header">
			<img class="logo_img" alt="" src="static/img/logo.gif" >
		</div>
		
			<div class="login_banner">
			
				<div id="l_content">
					<span class="login_word"><%=str1 %></span>
				</div>
				
				<div id="content">
					<div class="login_form">
						<div class="login_box">
							<div class="tit">
								<h1>大拇指书屋</h1>
								<a href="pages/user/regist.jsp"><span><%=str1 %></span></a>
							</div>
							<div class="msg_cont">
								<b></b>
								<span class="errorMsg">
									${ empty requestScope.msg ? "请输入用户名和密码":requestScope.msg }
								</span>
							</div>
							<div class="form">
								<form action="UserUpdateServlet?no=<%=id %>&pageCurrent2=<%=pageCurrent2 %>" method="post">
									<input type="hidden" name="action" value="login" />
									<br />
									<label>姓名：</label>
									<input id="name" class="itxt" type="text" 
										   autocomplete="off" tabindex="1" name="userName"
										   value="<%=userName %>" />
									<br />
									<br />
									<label>卡号：</label>
									<input id="password" class="itxt" type="text" value="<%=cardNumber %>"
										   autocomplete="off" tabindex="1" name="cardNumber" />
									<br />
									<br />
									<br/>
									<input type="submit"value="提交" id="sub_btn">
								</form>
							</div>
							
						</div>
					</div>
				</div>
			</div>

		<%--静态包含页脚内容--%>
		<%@include file="/pages/common/footer.jsp"%>
</body>
</html>